const OpenAI = require("openai");

const openai = new OpenAI({
    baseURL: 'https://api.deepseek.com',
    apiKey: 'sk-f6884c0f138248a19e8a9869da52952c',
    dangerouslyAllowBrowser: true 
})

const consult = {
    // 查询咨询记录列表接口
    async getAllConsultList(message) {
        console.log("【接收到的问题】",message);
        try {
            const completion = await openai.chat.completions.create({
                messages: [{ role: "system", content: "给我描述列举单词"+message+"的常见用法" }],
                model: "deepseek-chat",
                //修改处
                // stream:true
            });
            let result = completion.choices[0].message.content;
            console.log(completion.choices[0].message.content);
            return {success:true,data:result}
        } catch (err) {
            console.log('【err: in function getAllConsultList】', err);
            return { success: false ,result:'请求出错错误',message:message};
        }
    },
}

module.exports = consult;
